package com.slt.android.andfixdemo;

import android.content.pm.PackageManager;

import static android.R.attr.versionCode;

/**
 * Created by dp on 2018/4/11.
 */

public class AppInfoUtils {

    public static int getVersionCode(MyApplication myApplication) {
        int versionCodes = 0;
        try {
            versionCodes = myApplication.getPackageManager().
                    getPackageInfo(myApplication.getPackageName(), 0).versionCode;

        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return versionCodes;
    }
}
